package com.meihua.shellapp.adapter.personalcenter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.meihua.shellapp.R;
import com.meihua.shellapp.databean.IntegralDataBean;
import com.meihua.shellapp.utils.DateUtils;

import java.util.List;

/**
 * 作者：lc on 2017/9/27.
 * 邮箱：lc0607live@163.com
 */

public class MyIntegralAdapter extends RecyclerView.Adapter<MyIntegralAdapter.BrowseHandler> {
    private List<IntegralDataBean> mList;
    private Context mContext;

    public MyIntegralAdapter(Context context, List<IntegralDataBean> list) {
        mContext = context;
        mList = list;
    }

    @Override
    public BrowseHandler onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_integral, null);
        BrowseHandler handler = new BrowseHandler(view);
        return handler;
    }

    @Override
    public void onBindViewHolder(BrowseHandler holder, int position) {
        holder.tv_time.setText(DateUtils.getInstance().getTime(mList.get(position).getTime()));
        holder.tv_scorechange.setText(mList.get(position).getScorechange());
        holder.tv_remark.setText(mList.get(position).getRemark());
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class BrowseHandler extends RecyclerView.ViewHolder {
        TextView tv_time, tv_scorechange, tv_remark;

        public BrowseHandler(View itemView) {
            super(itemView);
            tv_time = itemView.findViewById(R.id.tv_time);
            tv_scorechange = itemView.findViewById(R.id.tv_scorechange);
            tv_remark = itemView.findViewById(R.id.tv_remark);
        }
    }
}
